package com.jbookshelf.beans;

import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import org.primefaces.context.RequestContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

@Component
@Scope("request")
public class TestBean {

	@PostConstruct
	public void postConstruct() {
//		System.out.println(String.format("%s postConstruct()", TestBean.class));
	}

	public void foo() {
//		System.out.println(String.format("%s foo()", TestBean.class));

		final RequestContext context = RequestContext.getCurrentInstance();
		context.execute("newUserDialog.show()");

		FacesMessage msg = new FacesMessage("I've just clicked button!", "Huuraaay!");
		FacesContext.getCurrentInstance().addMessage(null, msg);
	}

}
